<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <form action="">
    <input type="text" name="username">
    <input type="text" name="username1">
    <input type="text" name="username2">
    <input type="text" name="username3">
    <input type="text" name="username4">
    <input type="text" name="username5">
    <input type="text" name="username6">
    <input type="text" name="username7">
    <input type="text" name="username8">
    <input type="text" name="username9">
    <input type="text" name="username10">
    <input type="submit">
  </form>
  <script>
    /* document.forms[0].onsubmit = function () {
      // 发送ajax
      return false
    } */
  
  </script>
  <script src="../libs/jquery-1.12.4.js"></script>
  <script src="./jquery-validation-1.14.0/dist/jquery.validate.js"></script>
  <script>
    $(function () {
      $('form').validate({
        // validate提供了一个选项
        submitHandler: function () {
          // 在这里进行ajax的操作即可
          $.ajax({
            url: 'http://localhost',
            data: $('form').serialize()
          })
        },
        rules: {
          username: 'required'
        }
      })
    })
  
  </script>
</body>
</html>